package com.gpj.learn.rabbitmq.springboot.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @className Knife4jConfiguration
 * @description
 *   TODO
 * @author GPJ
 * @date 2021/6/8 13:46
 * @version 1.0
 **/
@Configuration
@EnableSwagger2
@EnableKnife4j
public class Knife4jConfiguration {
	@Bean
	public Docket defaultApi2() {
		Docket docket=new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.groupName("2.X版本") //分组名称
				.select()
				.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
				.paths(PathSelectors.any())
				.build();
		return docket;
	}
	
	private ApiInfo apiInfo(){
	    return new ApiInfoBuilder()
				.title("RabbitMQ与SpringBoot整合")
				.description("RabbitMQ与SpringBoot整合调试界面")
				.termsOfServiceUrl("http://localhost:8080/")
				.contact("guangpengju@163.com")
				.version("1.0")
				.build();
	}
}